<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <title>webrx</title>
</head>
<body>
<h3>客户端时间</h3>
<h1 id="ct"></h1>
<script>
    let c = document.querySelector('#ct')

    function cc() {
        let d = new Date()
        let year = d.getFullYear()
        let month = (d.getMonth() + 1).toString().padStart(2, 0)
        let date = d.getDate().toString().padStart(2, 0)
        let hh = d.getHours().toString().padStart(2, 0)
        let mi = d.getMinutes().toString().padStart(2, 0)
        let ss = d.getSeconds().toString().padStart(2, '0')
        c.innerHTML = `${year}年${month}月${date}日 ${hh}:${mi}:${ss}`
    }

    cc()
    setInterval(cc, 1000)
</script>
<h3>服务端时间</h3>
<h1 id="st"></h1>
<script>
    function getst() {
        let c = document.querySelector('#st')
        fetch('gettime.php').then(res => res.text()).then(data => {
            c.innerHTML = data
        })
    }

    getst()
    setInterval(getst, 1000)
</script>


</body>
</html>